package com.tc.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tc.dto.KhxxDTO;
import com.tc.domain.Customer;

import com.tc.service.CustomerService;
import com.tc.utils.ResultVo;
import com.tc.vo.KhxxCustomerVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jcd
 * @since 2025-06-23
 */


@RestController
@RequestMapping("/customer")
@CrossOrigin
@Api(tags = "客户管理")
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    @ApiOperation(value = "入住登记")
    @PostMapping("/rzdj")
    public ResultVo addCustomer(Customer customer) throws Exception {
        return customerService.addCustomer(customer);
    }

    @GetMapping("/listKhxxPage")
    @ApiOperation(value = "客户信息动态查询（分页）")
    public ResultVo<Page<KhxxCustomerVo>> listKhxxPage(KhxxDTO khxxDTO) throws Exception {
        return customerService.khxxFindCustomer(khxxDTO);
    }
    @GetMapping("/removeCustomer")
    @ApiOperation("删除客户信息")
    public ResultVo removeCustomer(Integer id) throws Exception {
        Customer customer = new Customer();
        customer.setIsDeleted(1);
        customer.setId(id);
        customerService.updateById(customer);
        return ResultVo.ok("删除成功");
    }
    @PostMapping("/editKhxx")
    @ApiOperation("编辑客户信息")
    public ResultVo editKhxx(Customer customer) throws Exception {
        customerService.updateById(customer);
        return ResultVo.ok("编辑成功");
    }

}


